load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")

package(default_visibility = ["//visibility:public"])

filegroup(
    name = "keys_hdrs",
    srcs = [
        "bn254_plonk_proving_key.h",
        "bn254_plonk_verifying_key.h",
    ],
)

tachyon_cc_library(
    name = "bn254_keys",
    deps = [":bn254_plonk_proving_key"],
)

tachyon_cc_library(
    name = "bn254_plonk_proving_key",
    srcs = ["bn254_plonk_proving_key.cc"],
    hdrs = ["bn254_plonk_proving_key.h"],
    deps = [
        ":bn254_plonk_verifying_key",
        ":proving_key_impl",
        "//tachyon/c/zk/plonk/halo2:bn254_ps",
        "//tachyon/zk/plonk/halo2:pcs_type",
    ],
)

tachyon_cc_library(
    name = "bn254_plonk_verifying_key",
    srcs = ["bn254_plonk_verifying_key.cc"],
    hdrs = [
        "bn254_plonk_verifying_key.h",
        "bn254_plonk_verifying_key_type_traits.h",
    ],
    deps = [
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/c/zk/plonk/constraint_system:bn254_constraint_system",
        "//tachyon/cc/math/elliptic_curves/bn/bn254:fr",
        "//tachyon/math/elliptic_curves/bn/bn254:g1",
        "//tachyon/zk/plonk/keys:verifying_key",
    ],
)

tachyon_cc_library(
    name = "keys",
    deps = [":bn254_keys"],
)

tachyon_cc_library(
    name = "proving_key_impl",
    hdrs = ["proving_key_impl.h"],
    deps = [
        "//tachyon/base:environment",
        "//tachyon/base:logging",
        "//tachyon/base/buffer",
        "//tachyon/base/files:file_util",
        "//tachyon/c/zk/plonk/halo2:buffer_reader",
        "//tachyon/zk/plonk/halo2:pinned_verifying_key",
        "//tachyon/zk/plonk/halo2:vendor",
        "//tachyon/zk/plonk/keys:proving_key",
        "@com_google_absl//absl/types:span",
    ],
)

tachyon_cc_unittest(
    name = "keys_unittests",
    srcs = [
        "bn254_plonk_proving_key_unittest.cc",
        "bn254_plonk_verifying_key_unittest.cc",
    ],
    deps = [
        ":bn254_plonk_proving_key",
        "//tachyon/c/zk/plonk/halo2:constants",
        "//tachyon/math/finite_fields/test:finite_field_test",
    ],
)
